package com.sc.nft.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.UserEcologyPointsWalletLog;
import com.sc.nft.entity.vo.AdminEcologyPointsUserWalletPageDetailsVO;
import com.sc.nft.entity.vo.PointsWalletLogConsumePointsVO;
import com.sc.nft.entity.vo.ecology.AdminEcologyPointsUserPageDetailsVO;
import com.sc.nft.enums.EcologyPointsEnum;
import com.sc.nft.mapper.UserEcologyPointsWalletLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author：LiGen
 * @Package：com.sc.nft.dao
 * @Project：sc_metago
 * @name：DaoEcologyPointsWalletDao
 * @Date：2024/11/26 11:08
 * @Filename：DaoEcologyPointsWalletDao
 */
@Slf4j
@Repository
public class UserEcologyPointsWalletLogDao extends ServiceImpl<UserEcologyPointsWalletLogMapper, UserEcologyPointsWalletLog> {


    public Page<AdminEcologyPointsUserWalletPageDetailsVO> getUserDetailsPage(Page<?> page, Long userId,Long walletId ,Integer type, Date startTime, Date endTime) {
        return baseMapper.getUserDetailsPage(page, userId,walletId, type, startTime, endTime);
    }

    /**
     * 总发放（不包含Dao）
     * 铸造消耗总积分  重铸消耗总积分 type : 铸造:2  重铸：24
     * @param pointsId
     * @param startTime
     * @param endTime
     * @return
     */
    public PointsWalletLogConsumePointsVO getConsumePoints(Long pointsId, Date startTime, Date endTime) {
        return baseMapper.getConsumePoints(pointsId, startTime, endTime);
    }

    /**
     * 根据条件统计
     * @param pointsId
     * @param startTime
     * @param endTime
     * @return
     */
    public BigDecimal getConditionWithPoints(Long pointsId, Boolean isAdd, EcologyPointsEnum type, Date startTime, Date endTime) {
        return baseMapper.getConditionWithPoints(pointsId,isAdd,type == null ? 0:type.getCode(), startTime, endTime);
    }
}
